home *** CD-ROM | disk | FTP | other *** search
/ Especial Multimedia / Especial Multimedia.iso / Multimed / Prg / KALENDAR.ZIP / TEST3.FRM < prev    next >
Text File  |  1997-09-14  |  8KB  |  270 lines

  1. VERSION 2.00
  2. Begin Form Form3 
  3.    BackColor       =   &H00C0C0C0&
  4.    Caption         =   "Drag 'N Drop (and DrawOnDay event)"
  5.    ClientHeight    =   3780
  6.    ClientLeft      =   3210
  7.    ClientTop       =   645
  8.    ClientWidth     =   7005
  9.    Height          =   4470
  10.    Left            =   3150
  11.    LinkTopic       =   "Form3"
  12.    ScaleHeight     =   3780
  13.    ScaleWidth      =   7005
  14.    Top             =   15
  15.    Width           =   7125
  16.    Begin PictureBox pctTop 
  17.       Align           =   1  'Align Top
  18.       BackColor       =   &H00C0C0C0&
  19.       Height          =   600
  20.       Left            =   0
  21.       ScaleHeight     =   570
  22.       ScaleWidth      =   6975
  23.       TabIndex        =   1
  24.       Top             =   0
  25.       Width           =   7005
  26.       Begin TextBox Text1 
  27.          DragIcon        =   TEST3.FRX:0000
  28.          Height          =   300
  29.          Left            =   4290
  30.          TabIndex        =   2
  31.          Text            =   "Text1"
  32.          Top             =   0
  33.          Width           =   2010
  34.       End
  35.       Begin Label Label2 
  36.          BackColor       =   &H00C0C0C0&
  37.          Caption         =   "Or, drag a date from the Kalendar to the Text Box or another date."
  38.          FontBold        =   0   'False
  39.          FontItalic      =   0   'False
  40.          FontName        =   "MS Sans Serif"
  41.          FontSize        =   8.25
  42.          FontStrikethru  =   0   'False
  43.          FontUnderline   =   0   'False
  44.          Height          =   210
  45.          Left            =   60
  46.          TabIndex        =   4
  47.          Top             =   300
  48.          Width           =   5775
  49.       End
  50.       Begin Label Label1 
  51.          BackColor       =   &H00C0C0C0&
  52.          Caption         =   "Type something here and drag it to the Kalendar."
  53.          FontBold        =   0   'False
  54.          FontItalic      =   0   'False
  55.          FontName        =   "MS Sans Serif"
  56.          FontSize        =   8.25
  57.          FontStrikethru  =   0   'False
  58.          FontUnderline   =   0   'False
  59.          Height          =   210
  60.          Left            =   75
  61.          TabIndex        =   3
  62.          Top             =   60
  63.          Width           =   4230
  64.       End
  65.    End
  66.    Begin Kalendar Kalendar1 
  67.       ArrowDelay      =   500
  68.       BackColor       =   &H00FFFFFF&
  69.       BorderStyle     =   1  'Fixed Single
  70.       CalendarFormat  =   0  'Month
  71.       ChgOnOtherMon   =   -1  'True
  72.       DateDispStyle   =   2  'User
  73.       DayAlignment    =   0  'Upper Left
  74.       DOWAlign        =   2  'Center
  75.       DOWBackColor    =   &H00808080&
  76.       DOWBorder       =   -1  'True
  77.       DOWDispStyle    =   2  'Medium
  78.       DOWFontBold     =   0   'False
  79.       DOWFontItalic   =   0   'False
  80.       DOWFontName     =   "Arial"
  81.       DOWFontSize     =   10
  82.       DOWFontStrikeThru=   0   'False
  83.       DOWFontUnderline=   0   'False
  84.       DOWForeColor    =   &H00FFFFFF&
  85.       DragIcon        =   TEST3.FRX:0302
  86.       EnableKeys      =   0   'False
  87.       FirstDOW        =   0  'Sunday
  88.       FixedDayHeight  =   0   'False
  89.       FontBold        =   -1  'True
  90.       FontItalic      =   0   'False
  91.       FontName        =   "Times New Roman"
  92.       FontSize        =   9.75
  93.       FontStrikethru  =   0   'False
  94.       FontUnderline   =   0   'False
  95.       ForeColor       =   &H00000000&
  96.       Height          =   3255
  97.       Language        =   0  'English
  98.       Left            =   0
  99.       LineColor       =   &H00000000&
  100.       MonAlign        =   2  'Center
  101.       MonBackColor    =   &H00C0C0C0&
  102.       MonDispStyle    =   2  'Month/Year
  103.       MonFontBold     =   0   'False
  104.       MonFontItalic   =   0   'False
  105.       MonFontName     =   "Times New Roman"
  106.       MonFontSize     =   14
  107.       MonFontStrikeThru=   0   'False
  108.       MonFontUnderline=   0   'False
  109.       MonForeColor    =   &H00000000&
  110.       OtherMonBackColor=   &H00C0C0C0&
  111.       OtherMonForeColor=   &H00FFFFFF&
  112.       SelDayBackColor =   &H00C0C0C0&
  113.       SelDayForeColor =   &H00000000&
  114.       ShowAllDays     =   0   'False
  115.       ShowArrows      =   -1  'True
  116.       ShowLines       =   -1  'True
  117.       ShowSelection   =   0   'False
  118.       TabIndex        =   0
  119.       Text            =   "06/16/94"
  120.       TextFormat      =   0  'mdy
  121.       Top             =   585
  122.       Width           =   6435
  123.    End
  124.    Begin Label lblFont 
  125.       Caption         =   "FontLable"
  126.       FontBold        =   0   'False
  127.       FontItalic      =   0   'False
  128.       FontName        =   "MS Sans Serif"
  129.       FontSize        =   8.25
  130.       FontStrikethru  =   0   'False
  131.       FontUnderline   =   0   'False
  132.       ForeColor       =   &H00008000&
  133.       Height          =   285
  134.       Left            =   6450
  135.       TabIndex        =   5
  136.       Top             =   1980
  137.       Visible         =   0   'False
  138.       Width           =   555
  139.    End
  140.    Begin Menu mnuFile 
  141.       Caption         =   "&File"
  142.       Begin Menu mnuFPrint 
  143.          Caption         =   "&Print"
  144.       End
  145.    End
  146. End
  147. Option Explicit
  148.  
  149. Dim draggingDay As Variant
  150.  
  151. Dim couldDrag As Integer
  152. Dim downAtX As Single, downAtY As Single
  153.  
  154. Dim txtHeight As Long       ' Used to determine how much space is required to show the day numbers.
  155.                 ' It is set differently for the printer and the screen.
  156.  
  157. Sub Form_Activate ()
  158.     SetDescription Sample3Description()
  159. End Sub
  160.  
  161. Sub Form_Load ()
  162.     Kalendar1.Text = Date
  163.  
  164.     txtHeight = TextHeight("I") / Screen.TwipsPerPixelY
  165. End Sub
  166.  
  167. Sub Form_Resize ()
  168.     If Form3.ScaleWidth > 0 And Form3.ScaleHeight - pctTop.Height > 0 Then
  169.     Kalendar1.Move 0, pctTop.Height, Form3.ScaleWidth, Form3.ScaleHeight - pctTop.Height
  170.     End If
  171. End Sub
  172.  
  173. Sub Kalendar1_DragDrop (Source As Control, x As Single, y As Single)
  174.     Kalendar1.PointX = x
  175.     Kalendar1.PointY = y
  176.  
  177.     If Kalendar1.DateAtPoint <> "" Then
  178.  
  179.     If TypeOf Source Is TextBox Then
  180.         DateInfoAdd (Kalendar1.DateAtPointJul), (Text1.Text)
  181.         Text1.Text = ""
  182.     Else
  183.         DateInfoMove (draggingDay), (Kalendar1.DateAtPointJul)
  184.     End If
  185.     Kalendar1.Refresh
  186.     End If
  187. End Sub
  188.  
  189. Sub Kalendar1_DrawOnDay (hDC As Integer, State As Integer, theDay As Long, x As Single, y As Single, x2 As Single, y2 As Single)
  190. Dim r As Rect
  191. Dim StrTmp As String
  192.     '--- Draw out some text
  193.     StrTmp = GetDateInfo(theDay)
  194.  
  195.     If Len(StrTmp) > 0 Then
  196.     '--- Make a Windows API rectangle to draw in.
  197.     KalWindowAPIRect x, y, x2, y2, r
  198.     InflateRect r, -1, -1
  199.     r.top = r.top + txtHeight
  200.     KalDrawText hDC, theDay, r, StrTmp, lblFont, False
  201.     End If
  202.     
  203. End Sub
  204.  
  205. Sub Kalendar1_MouseDown (Button As Integer, Shift As Integer, x As Single, y As Single)
  206.  
  207.     Kalendar1.PointX = x
  208.     Kalendar1.PointY = y
  209.  
  210.     If Kalendar1.DateAtPoint <> "" Then
  211.     downAtX = x
  212.     downAtY = y
  213.     couldDrag = True
  214.     End If
  215. End Sub
  216.  
  217. Sub Kalendar1_MouseMove (Button As Integer, Shift As Integer, x As Single, y As Single)
  218.  
  219.     If couldDrag And (Abs(downAtX - x) > 75 Or Abs(downAtY - y) > 75) Then
  220.     couldDrag = False
  221.     Kalendar1.Drag 1
  222.     draggingDay = Kalendar1.DateAtPointJul
  223.     End If
  224. End Sub
  225.  
  226. Sub Kalendar1_MouseUp (Button As Integer, Shift As Integer, x As Single, y As Single)
  227.  
  228.     couldDrag = False
  229.     Kalendar1.Drag 2
  230. End Sub
  231.  
  232. Sub mnuFPrint_Click ()
  233. Dim saveBackColor As Long
  234.  
  235.     saveBackColor = Kalendar1.MonBackColor
  236.     txtHeight = TextHeight("I") / Printer.TwipsPerPixelY
  237.  
  238.     Kalendar1.MonBackColor = RGB(255, 255, 255)
  239.     Kalendar1.PrintHDC = Printer.hDC
  240.     Kalendar1.PrintAction = KAL_PRINT_PORTRAIT
  241.     
  242.     Kalendar1.MonBackColor = saveBackColor
  243.     txtHeight = TextHeight("I") / Screen.TwipsPerPixelY
  244.     
  245.     Printer.EndDoc
  246. End Sub
  247.  
  248. Function Sample3Description () As String
  249. Dim s As String
  250.  
  251.     s = "This sample shows drag and drop implemented in a Kalendar. The "
  252.     s = s & "DrawOnDay event is used to display the text. " & CR
  253.     s = s & "NOTE: Maximize the window to see more of the text."
  254.  
  255.     Sample3Description = s
  256. End Function
  257.  
  258. Sub Text1_DragDrop (Source As Control, x As Single, y As Single)
  259.     Text1.Text = GetDateInfo((draggingDay))
  260. End Sub
  261.  
  262. Sub Text1_MouseDown (Button As Integer, Shift As Integer, x As Single, y As Single)
  263.     Text1.Drag 1
  264. End Sub
  265.  
  266. Sub Text1_MouseUp (Button As Integer, Shift As Integer, x As Single, y As Single)
  267.     Text1.Drag 2
  268. End Sub
  269.  
  270.